package com.fplanning.planner.domain;

public class FISlice
{

    private IFinancialInstrument fInstrument;
    private double weightPct;

    public final IFinancialInstrument getfInstrument()
    {
        return fInstrument;
    }

    public final void setfInstrument(IFinancialInstrument fInstrument)
    {
        this.fInstrument = fInstrument;
    }

    /**
     * @return the weightPct
     */
    public final double getWeightPct()
    {
        return weightPct;
    }

    /**
     * @param weightPct the weightPct to set
     */
    public final void setWeightPct(double weightPct)
    {
        this.weightPct = weightPct;
    }
    
    public double calculateAmount(double amount)
    {
        double result = 0;
        if(fInstrument!=null)
        {
            if(fInstrument.isAmountVariable())
            {
                result = weightPct*amount/100d;
            }
            else
            {
                result = fInstrument.getAmount();
            }
        }
        
        return result;
    }
    
    @Override
    public String toString()
    {
        return fInstrument.toString() + ":" + weightPct;
    }

}
